<?php
namespace Company\Controller;
use Think\Controller;
class UnitController extends BaseController {
    public function index(){
        $unit = M('unit');
        if(I("get.name")===null || I("get.name")===''){
            $where="1=1";
        }else{
            $where['unit_name']=array('LIKE',"%".trim(I("get.name")."%"));
        }
        if(I("get.sort")!=''){
            $order=I("get.sort")." ".I("get.dec");
        }else{
            $order='id desc';
        }
        $count      = $unit->where($where)->count();
        $Page       = new \Think\Page($count,15);
        $show       = $Page->show();
        $list = $unit->where($where)->order($order)->limit($Page->firstRow.','.$Page->listRows)->select();
        $this->assign('list',$list);
        $this->assign('page',$show);
        $this->count=$count;
        $this->display();
    }
    public function getUnit(){
        $list = M('unit')->order("id")->select();
        if($list){
            alert(1,$list);
        }else{
            alert(0,'暂无');
        }
    }
	public function getCoin(){
        $list = M('Coin')->order("id")->select();
        if($list){
            alert(1,$list);
        }else{
            alert(0,'暂无');
        }
    }
	public function getCountry(){
        $list = M('Country')->order("id")->select();
        if($list){
            alert(1,$list);
        }else{
            alert(0,'暂无');
        }
    }
}